/**
 * 
 */
package hihocoder;

import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class Jerry的奶酪 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int K = scanner.nextInt();
		boolean[][] Matix = new boolean[N][M];
		scanner.nextLine();
		for (int i = 0; i < N; i++) {
			String string = scanner.nextLine();
			for (int j = 0; j < M; j++) {
				if (string.charAt(j) == '0') {
					Matix[i][j] = true;
				} else {
					Matix[i][j] = false;
				}
			}
		}
		int[][] cakes = new int[K][2];
		for (int i = 0; i < K; i++) {
			cakes[i][0] = scanner.nextInt();
			cakes[i][1] = scanner.nextInt();
		}
		int maxCakeStatus = 1 << K;
		int[][][] dp = new int[N][M][maxCakeStatus];
		// for (int i = 0; i < N; i++) {
		// for (int j = 0; j < M; j++) {
		// for (int j2 = 0; j2 < maxCakeStatus; j2++) {
		// dp[i][j][j2] = -1;
		// }
		// }
		// }
		for (int j2 = 0; j2 < maxCakeStatus; j2++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < M; j++) {
					dp[i][j][j2] = -2;
				}
			}
		}

		dp[0][0][0] = 0;// 出发点
		getRes(N - 1, M - 1, maxCakeStatus - 1, Matix, dp, cakes);
		// for (int j2 = 0; j2 < maxCakeStatus; j2++) {
		// for (int i = 0; i < N; i++) {
		// for (int j = 0; j < M; j++) {
		// int tmp = Integer.MAX_VALUE;
		// for (int i1 = 0; i1 < 4; i1++) {
		// int x = i + neibors[i1][0];
		// int y = j + neibors[i1][1];
		// if (canVisit(x, y, Matix) && dp[x][y][j2] != -1) {
		// tmp = Math.min(tmp, dp[x][y][j2]);
		// }
		// }
		// if (tmp != Integer.MAX_VALUE) {
		// dp[i][j][j2] = tmp + 1;
		// int jCake = j2;
		// for (int l = 0; l < cakes.length; l++) {
		// if (cakes[l][0] == i && cakes[l][1] == j) {
		// jCake |= (1 << l);
		// }
		// }
		// dp[i][j][jCake] = tmp + 1;
		// }
		// }
		// }
		// }
		System.out.println(dp[N - 1][M - 1][maxCakeStatus - 1]);
	}

	private static void getRes(int i, int j, int j2, boolean[][] matix, int[][][] dp, int[][] cakes) {
		System.out.println(i + " " + j + " " + j2 + " " + dp[i][j][j2]);

		int jCake = j2;
		for (int l = 0; l < cakes.length; l++) {
			if (cakes[l][0] == i && cakes[l][1] == j && (jCake & (1 << l)) != 0) {// 现在有这个奶酪
				jCake -= (1 << l);
			}
		}
		for (int i1 = 0; i1 < 4; i1++) {
			int x = i + neibors[i1][0];
			int y = j + neibors[i1][1];
			if (!canVisit(x, y, matix))
				continue;
			if (dp[x][y][jCake] == -2) {// 没计算过
				getRes(x, y, jCake, matix, dp, cakes);
			}
			if (dp[x][y][jCake] != -1) {
				if (dp[i][j][jCake] == -2 || dp[i][j][jCake] > +1) {
					dp[i][j][jCake] = dp[x][y][jCake] + 1;
				}
			}
		}
		dp[i][j][j2] = -1;// 不可达
	}

	static int neibors[][] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

	private static boolean canVisit(int x, int y, boolean[][] matix) {
		return x >= 0 && x < matix.length && y >= 0 && y < matix[0].length && matix[x][y];
	}
}
